<@master template="master/master-loan"  title="机构管理" appendCss="css.bootstrap">
<@css href="/js/public/ztree/css/zTreeStyle/zTreeStyle.css"/>
<div class="row" style="opacity: 1;">
	<div id="orgList" style="display:none;">${orgList}</div>
	<div class="col-lg-12">
        <div class="detailsBox">
            <h3><p class="fr">
            	<@permission permissionName="org_add_person">
            	<a data-url="<@url value='/organ/rest/add/employeePopup'/>" class="action-ajax-btn edit btn_blue">添加人员</a>
            	</@permission>	
            	<@permission permissionName="org_save">
            	<a id="save_menu" class="edit btn_blue">保存</a>
            	</@permission>	
            	</p><i class="jtIco"></i>机构管理
            </h3>
            <div class="main-box-body clearfix mt10">
                    <div class="col-sm-4">
							<div>机构列表</div>
                            <div class="mt10 clearfix">
                                <ul id="treeDiv" class="ztree"></ul>
                            </div>
                    </div>
                    <div class="col-lg-6">
						<div>
							<div class="cktitle action-toggle-closest-class" data-toggle-closest-class="showInfo" style="margin:10px 0 20px;"><span class="ckIco"></span>编辑机构</div>
                            <div class="mt10 clearfix ck-info1">
                                <form id="menu_edit" role="form" class="form-horizontal action-ajax-form" method="POST">
                                    <input type="hidden" id="menu_id" name="orgId" value=""/>
                                    <div class="formGroup">
                                        <span class="control-label" for="description">机构名称</span>
                                        <input type="text"  id="orgName" name="orgName" class="form-control"/>
                                    </div>
                                    <div class="formGroup">
                                        <span class="control-label" for="name">EA经营单位编号</span>
                                        <input type="text"  id="unitCode" name="unitCode" class="form-control"/>
                                    </div>
                                    <div class="formGroup">
                                        <span class="control-label" for="parentName">上级菜单</span>
										<input type="text" id="parentName" class="form-control" readonly/>
                                        <input type="hidden" id="parentId" name="parentId" class="form-control"/>
                                    </div>
                                    <div class="formGroup">
                                        <span class="control-label" for="resourceType">机构层级</span>
                                        <select class="form-control" name="orgLevel" id="orgLevel">
											<option value="1">战区</option>
											<option value="2">省区</option>
											<option value="4">省区金融部</option>
											<option value="9">平台</option>
										</select>
                                    </div>
                                    <div class="formGroup">
                                        <span class="control-label" for="orgFullName">公司全称</span>
										<input type="text" id="orgFullName" name="orgFullName"  class="form-control" value=""/>
                                    </div>
                                    <div class="formGroup">
                                        <span class="control-label" for="officeAddress">办公地址</span>
										<input type="text" id="officeAddress" name="officeAddress"  class="form-control" value=""/>
                                    </div>
                                    <div class="formGroup">
                                        <span class="control-label" for="sponsorTel">信贷经理电话</span>
										<input type="text" id="sponsorTel" name="sponsorTel"  class="form-control" value=""/>
                                    </div>
                                    <div class="formGroup">
                                        <span class="control-label" for="registerAddress">注册地址</span>
										<input type="text" id="registerAddress" name="registerAddress"  class="form-control" value=""/>
                                    </div>
                                    <div id="isNaturalProvinceDiv" class="formGroup" style="display:none;">
                                        <span class="control-label" for="registerAddress">自然省</span>
										<label> <input type="radio" name="isNaturalProvince" value="1" checked="checked">是</label>
 										<label> <input type="radio" name="isNaturalProvince" value="2" >否</label>
                                    </div>
                                    <div id="isPlatformDiv" class="formGroup" style="display:none;">
                                        <span class="control-label" for="registerAddress">平台地址</span>
										<select id="select_provinceId" name="province" onchange="provinceOnchange()"></select>&nbsp;&nbsp; 
			                    		<select id="select_areaId" name="city"></select>
                                    </div>
                                </form>
                       		 </div>
                       		 
                       		 </div>
                       		 <input type="hidden" id="ftlFlag"  value="organInfo"/>
                       		 <div id="dataTable" class="dataBable mt20" style="overflow-y:hidden"></div>
                       		 
                   	 </div>
                </div>
            </div>
        </div>
    </div>
</@master>
<@js src="/js/public/ztree/js/jquery.ztree.core.min.js;/js/public/ztree/js/jquery.ztree.excheck.min.js;/js/public/ztree/js/jquery.ztree.exedit.min.js;/js/o2o-admin/sys/common/treeMenu.js;/js/o2o-admin/sys/organ/details.js"/><@jsRender/>
<script>
	//省市区三级联动
	provinceLoad();
	function provinceLoad(){
		var provinceCode = $("#select_provinceId").attr('value');
		$.ajax({
			type: "GET",
			url:"${crmUrl}/common/findProvinces",
			dataType:"jsonp",
			jsonp:"_callback",
			success:function(result){
					$("#select_provinceId").empty();
					 $("#select_provinceId").append("<option value=''>请选择</option>"); 
					 $("#select_areaId").empty();
					 $("#select_areaId").append("<option value=''>请选择</option>"); 
					 $.each(result.data,function(key,value){
					 	if(provinceCode == value[0])
						    $("#select_provinceId").append("<option value='"+value[0]+"' selected='selected'>"+value[1]+"</option>");   
						else
							$("#select_provinceId").append("<option value='"+value[0]+"'>"+value[1]+"</option>");     
					 });
					 provinceOnchange();
		 		}
	 	});
     };
	
	
	function provinceOnchange(callback){
		var provinceCode = $("#select_provinceId").val() || $("#select_provinceId").attr('value');
		var areaCode = $("#select_areaId").val() || $("#select_areaId").attr('value');
		if(!provinceCode){
			 $("#select_areaId").empty();
			 $("#select_areaId").append("<option value=''>请选择</option>"); 
			 return true;
		}
		$.ajax({
			type: "GET",
			url:"${crmUrl}/common/findCityByProvinceCode",
			data:{provinceCode:provinceCode},
			dataType:"jsonp",
			jsonp:"_callback",
			success:function(result){
					 $("#select_areaId").empty();
					 $("#select_areaId").append("<option value=''>请选择</option>"); 
					 $.each(result.data,function(key,value){
					 	if(areaCode == value[0])
						    $("#select_areaId").append("<option value='"+value[0]+"' selected='selected'>"+value[1]+"</option>");   
						else
					 		$("#select_areaId").append("<option value='"+value[0]+"'>"+value[1]+"</option>");   
						 
					 });
					  callback &&　callback();
		 		}
	 	});
     }
	      
</script>
